﻿using System;
using System.Windows.Forms;
using Conusic;

namespace ConusicUI
{
	/// <summary>
	/// Description of AuthFormCommand.
	/// </summary>
	internal sealed class FormAuthCommand : Conusic.IAuthorizationCommand
	{
		private IFormAuth form;
		public FormAuthCommand (IFormAuth form){
			
			this.form = form;
			this.captchaHandler = new CaptchaDialog();
			SetEnableFormIfEstas(false);
		}
		
		public Conusic.Captcha captchaHandler {
			get;
			set;
		}
		
		public void Execute(string sid)
		{
			SetEnableFormIfEstas(true);
			form.SuccessAuthorization(sid);
		}
		
		public void FailAuthorization(Exception exception)
		{
			SetEnableFormIfEstas(true);
			

		}

		private void SetEnableFormIfEstas(bool en)
		{
			//if (form is Form) {
			//	(form as Form).Enabled = en;
			//}
		}
	}
}
